/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * jifAprobarRequerrimientos.java
 *
 * Created on 06-ago-2010, 10:23:43
 */

package Requerrimientos;

import administracion.delegate.GestionPedidosDelegate;
import administracion.helper.Listas;
import administracion.helper.MiTablePrint;
import administracion.helper.Utiles_MensajesDialogo;
import administracion.helper.Utiles_Tabla;
import com.jidesoft.hints.ListDataIntelliHints;
import java.awt.event.KeyEvent;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jdesktop.beansbinding.AutoBinding;
import org.jdesktop.beansbinding.BindingGroup;
import org.jdesktop.beansbinding.ELProperty;
import org.jdesktop.swingbinding.JTableBinding;
import org.jdesktop.swingbinding.SwingBindings;
import suministros.ejb30.TO.AnoTO;
import suministros.ejb30.TO.CentroCostoTO;
import suministros.ejb30.TO.MesTO;
import suministros.ejb30.TO.NecesidadesSumiDetalleTO;
import suministros.ejb30.TO.NecesidadesSumiTO;
import suministros.ejb30.TO.PedidoTO;
import suministros.ejb30.TO.ProyectoTO;
import suministros.ejb30.TO.UnidadOrganizativaTO;
import suministros.ejb30.TO.ZonaTO;
import suministros.ejb30.entity.CentroCosto;
import suministros.ejb30.entity.Parametros;
import suministros.ejb30.entity.Proyecto;
import suministros.ejb30.entity.UnidadOrganizativa;
import suministros.ejb30.helper.Utiles_Convertir;

/**
 *
 * @author Diana
 */
public class jifAprobarRequerrimientos extends javax.swing.JInternalFrame {
    private UnidadOrganizativa unid_org_pedido;
    private CentroCosto centro_costos_pedido;
    private Proyecto proyecto_pedido;
    private ListDataIntelliHints intelliHintsUnidOrganica;
    private ListDataIntelliHints intelliHintsCentroCostos;
    private ListDataIntelliHints intelliHintsProyectos;
    private List<NecesidadesSumiTO> requerimientos,tareasRequerimientos=new ArrayList(1);
    private List<NecesidadesSumiDetalleTO> detalleRequerimientos;
    private JTableBinding jTableBinding;
    private BindingGroup bindingGroup;
    boolean modificable;
    /** Creates new form jifAprobarRequerrimientos */
    public jifAprobarRequerrimientos() {
        initComponents();
        this.jbAceptar1.setVisible(modificable);
        cargaHintsIndependientes();
        if(this.jchkInversion.isSelected()){
            this.jpOperativo.setVisible(false);
            this.jpInversion.setVisible(true);
        }else{
            this.jpOperativo.setVisible(true);
            this.jpInversion.setVisible(false);
        }
    }
   private void cargaHintsIndependientes() {
        this.intelliHintsUnidOrganica = new ListDataIntelliHints(this.jtfDesUnOrganica, Listas.getUn_organizativa());
        this.intelliHintsProyectos= new ListDataIntelliHints(this.jtfDesProyecto,Listas.getProyectos());
  }

       private void limpiar(){
         if(this.jchkInversion.isSelected()){
            this.jpOperativo.setVisible(false);
            this.jpInversion.setVisible(true);
        }else{
            this.jpOperativo.setVisible(true);
            this.jpInversion.setVisible(false);
        }
        this.jtfCodCenCostos.setText("");
        this.jtfCodProyecto.setText("");
        this.jtfCodUnorganica.setText("");
        this.jtfDesProyecto.setText("");
        this.jtfDesUnOrganica.setText("");
        this.jtfDescCenCostos.setText("");
        this.unid_org_pedido=null;
        this.centro_costos_pedido=null;
        this.proyecto_pedido=null;
        this.jbAceptar1.setEnabled(false);
        this.requerimientos.clear();
        this.tareasRequerimientos.clear();
        this.actualizaTablaRequerimientos();
        this.pack();
    }
        private void actualizaTablaRequerimientos() {
       try{
           this.bindingGroup = new BindingGroup();
           this.jTableBinding = SwingBindings.createJTableBinding(AutoBinding.UpdateStrategy.READ, this.requerimientos, this.jtRequerimientos);

            JTableBinding.ColumnBinding columnBinding0 = this.jTableBinding.addColumnBinding(ELProperty.create("${id_suministro}"));

            columnBinding0.setColumnName("ID Suministro");
            columnBinding0.setColumnClass(String.class);
            columnBinding0.setEditable(false);

            JTableBinding.ColumnBinding columnBinding1 = this.jTableBinding.addColumnBinding(ELProperty.create("${descripcion_suministro}"));

            columnBinding1.setColumnName("Suministro");
            columnBinding1.setColumnClass(String.class);
            columnBinding1.setEditable(false);

            JTableBinding.ColumnBinding columnBinding2 = this.jTableBinding.addColumnBinding(ELProperty.create("${unidad_medida}"));

            columnBinding2.setColumnName("Unid.Medida");
            columnBinding2.setColumnClass(String.class);
            columnBinding2.setEditable(false);

             JTableBinding.ColumnBinding columnBinding3 = this.jTableBinding.addColumnBinding(ELProperty.create("${cantidad_total}"));

            columnBinding3.setColumnName("SUB TOTAL");
            columnBinding3.setColumnClass(BigDecimal.class);
            columnBinding3.setEditable(false);

            this.bindingGroup.addBinding(this.jTableBinding);
            this.bindingGroup.bind();

              int[] porcentajes= {20,50,15,15};
                try {
                     Utiles_Tabla.definirAnchoColumnasJTable(jtRequerimientos, porcentajes);
                     //MiTablePrint.autoSizeTableColumns(this.jtRequerimientos);
                } catch (Exception ex) {
                    Logger.getLogger(jifAdministrarRequerimientos.class.getName()).log(Level.SEVERE, null, ex);
                }


       }catch(Exception e){
           Utiles_MensajesDialogo.mensajeAlerta("Error al actualizar requerimientos\n"+e.getMessage());
           e.printStackTrace();
       }


   }



   private void buscarUnidOrganica()
  {
        List centros_hints;
        UnidadOrganizativaTO unoorg;
        if(this.jtfCodUnorganica.getText().trim().length() < 1)
        {
            unoorg = (UnidadOrganizativaTO)intelliHintsUnidOrganica.getSelectedHint();
            centros_hints = Listas.getCentro_Costos_Unid_Organica(unoorg.getCod_Uni_Organizativa().trim());
        } else
        {
            unoorg = Listas.getUn_organizativa_codigo(jtfCodUnorganica.getText().trim());
            centros_hints = Listas.getCentro_Costos_Unid_Organica(jtfCodUnorganica.getText().trim());
        }
        if(centros_hints.size() < 1)
        {
            Utiles_MensajesDialogo.mensajeError("La unidad organica no existe!");
            this.jtfDesUnOrganica.setText("");
            unid_org_pedido = null;
                try{
                    intelliHintsCentroCostos.getCompletionList().clear();
                    intelliHintsCentroCostos = null;
                }catch(NullPointerException e){

                }

        } else
        {
            unid_org_pedido = Utiles_Convertir.convertirToUnidadOrganizativa_UnidadOrganizativaTO(unoorg);
            jtfDesUnOrganica.setText(unoorg.toString());
            jtfCodUnorganica.setText(unoorg.getCod_Uni_Organizativa());
            if(intelliHintsCentroCostos != null)
            {
                intelliHintsCentroCostos.getCompletionList().clear();
                intelliHintsCentroCostos = null;
                jtfCodCenCostos.setText("");
                this.jtfDescCenCostos.setText("");
            }
            intelliHintsCentroCostos = new ListDataIntelliHints(jtfDescCenCostos, centros_hints);
            jtfCodCenCostos.requestFocus();
        }
  }

   private void buscarCentroCostos()
  {
    CentroCostoTO centro_cost;
    if (this.jtfCodCenCostos.getText().trim().length() < 1) {

      try { centro_cost = (CentroCostoTO)this.intelliHintsCentroCostos.getSelectedHint();
      } catch (NullPointerException ex) {
        centro_cost = null;
      }
    } else {
      centro_cost = Listas.getCentro_Costos_codigo(this.jtfCodCenCostos.getText().trim());
    }

    if (centro_cost == null) {
      Utiles_MensajesDialogo.mensajeError("El centro de costos no existe!");
      this.jtfDescCenCostos.setText("");
      this.centro_costos_pedido = null;
    } else {
      this.jtfDescCenCostos.setText(centro_cost.toString());
      this.jtfCodCenCostos.setText(centro_cost.getCod_CentroCosto());
      this.centro_costos_pedido = Utiles_Convertir.convertirToCentroCosto_CentroCostoTO(centro_cost);
      llenaTablaRequerimientos();
    }
  }
private void buscarProyectos()
  {
    ProyectoTO proyecto;
    if (this.jtfCodProyecto.getText().trim().length() < 1) {

      try { proyecto = (ProyectoTO)this.intelliHintsProyectos.getSelectedHint();
      } catch (NullPointerException ex) {
        proyecto = null;
      }
    } else {
      proyecto = Listas.getProyectoCodigo(this.jtfCodProyecto.getText().trim());
    }

    if (proyecto == null) {
      Utiles_MensajesDialogo.mensajeError("El proyecto no existe!");
      this.jtfDesProyecto.setText("");
      this.proyecto_pedido = null;
    } else {
      this.jtfDesProyecto.setText(proyecto.toString());
      this.jtfCodProyecto.setText(proyecto.getId_proyecto());
      this.proyecto_pedido = Utiles_Convertir.convertirToProyecto_ProyectoTO(proyecto);
      this.llenaTablaRequerimientos();
    }
  }
     protected void llenaTablaRequerimientos(){
       Parametros param;
        try {
            param = Listas.getParametrosID("SU1");

            String ano = param.getParam1();
            String mes = param.getParam2();
            if(this.jchkInversion.isSelected()){
               // this.requerimientos = GestionPedidosDelegate.getInstance().getListaNecesidadesInversion(this.proyecto_pedido.getIdProyecto().trim(), ano);
                //this.detalleRequerimientos=GestionPedidosDelegate.getInstance().getListaDetalleNecesidadesLocalidadInversion(this.proyecto_pedido.getIdProyecto().trim(), ano);
            }else{
                //this.requerimientos = GestionPedidosDelegate.getInstance().getListaNecesidadesOperativas(this.centro_costos_pedido.getCodCentroCosto().trim(), ano);
               // this.detalleRequerimientos=GestionPedidosDelegate.getInstance().getListaDetalleNecesidadesLocalidadOperativo(this.centro_costos_pedido.getCodCentroCosto().trim(), ano);
            }


            this.bindingGroup = new BindingGroup();
            this.jTableBinding = SwingBindings.createJTableBinding(AutoBinding.UpdateStrategy.READ, this.requerimientos, this.jtRequerimientos);

            JTableBinding.ColumnBinding columnBinding0 = this.jTableBinding.addColumnBinding(ELProperty.create("${id_suministro}"));

            columnBinding0.setColumnName("ID Suministro");
            columnBinding0.setColumnClass(String.class);
            columnBinding0.setEditable(false);

            JTableBinding.ColumnBinding columnBinding1 = this.jTableBinding.addColumnBinding(ELProperty.create("${descripcion_suministro}"));

            columnBinding1.setColumnName("Suministro");
            columnBinding1.setColumnClass(String.class);
            columnBinding1.setEditable(false);

            JTableBinding.ColumnBinding columnBinding2 = this.jTableBinding.addColumnBinding(ELProperty.create("${unidad_medida}"));

            columnBinding2.setColumnName("Unid.Medida");
            columnBinding2.setColumnClass(String.class);
            columnBinding2.setEditable(false);

             JTableBinding.ColumnBinding columnBinding3 = this.jTableBinding.addColumnBinding(ELProperty.create("${cantidad_total}"));

            columnBinding3.setColumnName("SUB TOTAL");
            columnBinding3.setColumnClass(BigDecimal.class);
            columnBinding3.setEditable(false);

            this.bindingGroup.addBinding(this.jTableBinding);
            this.bindingGroup.bind();

              int[] porcentajes= {20,50,15,15};
                try {
                  Utiles_Tabla.definirAnchoColumnasJTable(this.jtRequerimientos, porcentajes);
                  //MiTablePrint.autoSizeTableColumns(this.jtRequerimientos);
                } catch (Exception ex) {
                    Logger.getLogger(jifAdministrarRequerimientos.class.getName()).log(Level.SEVERE, null, ex);
                }

            if(this.requerimientos.size()>0){
            }else{

            }

    } catch (Exception ex) {
            Utiles_MensajesDialogo.mensajeError("Error al consultar Requerimientos\n"+ex.getMessage());
            return;
        }
   }


    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        cboBeanBindingAno1 = new administracion.BeanBinding.CboBeanBindingAno();
        cboBeanBindingMes1 = new administracion.BeanBinding.CboBeanBindingMes();
        cboBeanBindingZona1 = new administracion.BeanBinding.CboBeanBindingZona();
        jPanel1 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jtRequerimientos = new javax.swing.JTable();
        this.jtRequerimientos.getTableHeader().setReorderingAllowed(false) ;
        jbAceptar1 = new javax.swing.JButton();
        jbCancelar1 = new javax.swing.JButton();
        jpInversion = new javax.swing.JPanel();
        jLabel9 = new javax.swing.JLabel();
        jtfCodProyecto = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        jtfDesProyecto = new javax.swing.JTextField();
        jpOperativo = new javax.swing.JPanel();
        jLabel5 = new javax.swing.JLabel();
        jtfCodUnorganica = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        jtfDesUnOrganica = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        jtfCodCenCostos = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        jtfDescCenCostos = new javax.swing.JTextField();
        jchkInversion = new javax.swing.JCheckBox();
        jbtImprimir1 = new javax.swing.JButton();

        setIconifiable(true);
        setTitle("APROBAR REQUERRIMIENTOS");

        jtRequerimientos.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        jtRequerimientos.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "ID SUMINISTRO", "SUMINISTRO", "UNID.MEDIDA", "SUB TOTAL", "PRECIO UNIT.", "MONTO", "MONTO MAXIMO"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Double.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }
        });
        jtRequerimientos.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jScrollPane1.setViewportView(jtRequerimientos);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap(13, Short.MAX_VALUE)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 732, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 257, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jbAceptar1.setFont(new java.awt.Font("Arial", 0, 12));
        jbAceptar1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconoscomb/16x16ozygen/actions/button_ok.png"))); // NOI18N
        jbAceptar1.setMnemonic('A');
        jbAceptar1.setText("ACEPTAR");
        jbAceptar1.setEnabled(false);
        jbAceptar1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbAceptar1ActionPerformed(evt);
            }
        });

        jbCancelar1.setFont(new java.awt.Font("Arial", 0, 12));
        jbCancelar1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconoscomb/16x16ozygen/actions/button_cancel.png"))); // NOI18N
        jbCancelar1.setMnemonic('C');
        jbCancelar1.setText("CANCELAR");
        jbCancelar1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbCancelar1ActionPerformed(evt);
            }
        });

        jLabel9.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel9.setText("COD.PROYECTO");

        jtfCodProyecto.setToolTipText("Codigo de la unidad organica");
        jtfCodProyecto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtfCodProyectoActionPerformed(evt);
            }
        });

        jLabel10.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel10.setText("DESC.PROYECTO");

        jtfDesProyecto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtfDesProyectoActionPerformed(evt);
            }
        });
        jtfDesProyecto.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jtfDesProyectoKeyPressed(evt);
            }
        });

        javax.swing.GroupLayout jpInversionLayout = new javax.swing.GroupLayout(jpInversion);
        jpInversion.setLayout(jpInversionLayout);
        jpInversionLayout.setHorizontalGroup(
            jpInversionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpInversionLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jtfCodProyecto, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jLabel10)
                .addGap(29, 29, 29)
                .addComponent(jtfDesProyecto, javax.swing.GroupLayout.PREFERRED_SIZE, 386, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jpInversionLayout.setVerticalGroup(
            jpInversionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpInversionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jLabel9)
                .addComponent(jtfCodProyecto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(jLabel10)
                .addComponent(jtfDesProyecto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        jLabel5.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel5.setText("COD.UN.ORGAN.");

        jtfCodUnorganica.setToolTipText("Codigo de la unidad organica");
        jtfCodUnorganica.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtfCodUnorganicaActionPerformed(evt);
            }
        });

        jLabel6.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel6.setText("DESC.UN.ORGAN.");

        jtfDesUnOrganica.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtfDesUnOrganicaActionPerformed(evt);
            }
        });
        jtfDesUnOrganica.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jtfDesUnOrganicaKeyPressed(evt);
            }
        });

        jLabel7.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel7.setText("COD.CEN.COSTOS");

        jtfCodCenCostos.setFont(new java.awt.Font("Arial 12 Simple", 0, 12));
        jtfCodCenCostos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtfCodCenCostosActionPerformed(evt);
            }
        });

        jLabel8.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel8.setText("DESC.CEN.COSTOS");

        jtfDescCenCostos.setFont(new java.awt.Font("Arial 12 Simple", 0, 12));
        jtfDescCenCostos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtfDescCenCostosActionPerformed(evt);
            }
        });
        jtfDescCenCostos.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jtfDescCenCostosKeyPressed(evt);
            }
        });

        javax.swing.GroupLayout jpOperativoLayout = new javax.swing.GroupLayout(jpOperativo);
        jpOperativo.setLayout(jpOperativoLayout);
        jpOperativoLayout.setHorizontalGroup(
            jpOperativoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpOperativoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jpOperativoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel5)
                    .addComponent(jLabel7))
                .addGroup(jpOperativoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jpOperativoLayout.createSequentialGroup()
                        .addGap(17, 17, 17)
                        .addComponent(jtfCodUnorganica, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jpOperativoLayout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addComponent(jtfCodCenCostos, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(18, 18, 18)
                .addGroup(jpOperativoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel6)
                    .addComponent(jLabel8))
                .addGap(18, 18, 18)
                .addGroup(jpOperativoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jtfDescCenCostos)
                    .addComponent(jtfDesUnOrganica, javax.swing.GroupLayout.DEFAULT_SIZE, 382, Short.MAX_VALUE))
                .addContainerGap(11, Short.MAX_VALUE))
        );

        jpOperativoLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jtfDesUnOrganica, jtfDescCenCostos});

        jpOperativoLayout.setVerticalGroup(
            jpOperativoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpOperativoLayout.createSequentialGroup()
                .addGroup(jpOperativoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(jtfCodUnorganica, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6)
                    .addComponent(jtfDesUnOrganica, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jpOperativoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(jtfCodCenCostos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel8)
                    .addComponent(jtfDescCenCostos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
        );

        jchkInversion.setFont(new java.awt.Font("Arial", 1, 12));
        jchkInversion.setText("DE INVERSION");
        jchkInversion.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jchkInversionActionPerformed(evt);
            }
        });

        jbtImprimir1.setFont(new java.awt.Font("Arial", 1, 12));
        jbtImprimir1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconoscomb/16x16ozygen/actions/document_print.png"))); // NOI18N
        jbtImprimir1.setText("IMPRIMIR");
        jbtImprimir1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtImprimir1ActionPerformed(evt);
            }
        });
        jbtImprimir1.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jbtImprimir1KeyPressed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(144, Short.MAX_VALUE)
                .addComponent(jbtImprimir1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jbAceptar1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jbCancelar1)
                .addGap(280, 280, 280))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(7, 7, 7)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jchkInversion)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 657, Short.MAX_VALUE))
                    .addComponent(jpOperativo, javax.swing.GroupLayout.DEFAULT_SIZE, 762, Short.MAX_VALUE)
                    .addComponent(jpInversion, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(14, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jchkInversion)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jpOperativo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jpInversion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 38, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jbCancelar1)
                    .addComponent(jbAceptar1)
                    .addComponent(jbtImprimir1)))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jbAceptar1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbAceptar1ActionPerformed


}//GEN-LAST:event_jbAceptar1ActionPerformed

    private void jbCancelar1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbCancelar1ActionPerformed
        
        int res = javax.swing.JOptionPane.showConfirmDialog( this,"Esta seguro de salir?",
                "Confirmar",javax.swing.JOptionPane.YES_NO_OPTION );
        if(res==javax.swing.JOptionPane.YES_OPTION){

            this.dispose();

        }
}//GEN-LAST:event_jbCancelar1ActionPerformed

    private void jtfCodProyectoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtfCodProyectoActionPerformed
        
        if (this.jtfCodProyecto.getText().trim().length() < 1)
            this.jtfDesProyecto.requestFocus();
        else
            buscarProyectos();
}//GEN-LAST:event_jtfCodProyectoActionPerformed

    private void jtfDesProyectoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtfDesProyectoActionPerformed
       
        buscarProyectos();
}//GEN-LAST:event_jtfDesProyectoActionPerformed

    private void jtfDesProyectoKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtfDesProyectoKeyPressed
       
        if (this.jtfCodProyecto.getText().trim().length() > 0)
            this.jtfCodProyecto.setText("");
}//GEN-LAST:event_jtfDesProyectoKeyPressed

    private void jtfCodUnorganicaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtfCodUnorganicaActionPerformed
       
        if (this.jtfCodUnorganica.getText().trim().length() < 1)
            this.jtfDesUnOrganica.requestFocus();
        else
            buscarUnidOrganica();
}//GEN-LAST:event_jtfCodUnorganicaActionPerformed

    private void jtfDesUnOrganicaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtfDesUnOrganicaActionPerformed
      
        buscarUnidOrganica();
}//GEN-LAST:event_jtfDesUnOrganicaActionPerformed

    private void jtfDesUnOrganicaKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtfDesUnOrganicaKeyPressed
       
        if (this.jtfCodUnorganica.getText().trim().length() > 0)
            this.jtfCodUnorganica.setText("");
}//GEN-LAST:event_jtfDesUnOrganicaKeyPressed

    private void jtfCodCenCostosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtfCodCenCostosActionPerformed
       
        if (this.jtfCodCenCostos.getText().trim().length() < 1)
            this.jtfDescCenCostos.requestFocus();
        else
            buscarCentroCostos();
}//GEN-LAST:event_jtfCodCenCostosActionPerformed

    private void jtfDescCenCostosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtfDescCenCostosActionPerformed
       
        buscarCentroCostos();
}//GEN-LAST:event_jtfDescCenCostosActionPerformed

    private void jtfDescCenCostosKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtfDescCenCostosKeyPressed
        
        if (this.jtfCodCenCostos.getText().trim().length() > 0)
            this.jtfCodCenCostos.setText("");
}//GEN-LAST:event_jtfDescCenCostosKeyPressed

    private void jchkInversionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jchkInversionActionPerformed
        

        this.limpiar();
}//GEN-LAST:event_jchkInversionActionPerformed

    private void jbtImprimir1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtImprimir1ActionPerformed

        MiTablePrint pp = new MiTablePrint(this.jtRequerimientos, "REQUERRIMIENTOS", "DETALLE DE REQUERRIMIENTOS APROBADOS");
        pp.showPrintPreview();
}//GEN-LAST:event_jbtImprimir1ActionPerformed

    private void jbtImprimir1KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jbtImprimir1KeyPressed
        if (evt.getKeyCode() == KeyEvent.VK_ENTER ){
            this.jbtImprimir1.doClick();
        }
}//GEN-LAST:event_jbtImprimir1KeyPressed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private administracion.BeanBinding.CboBeanBindingAno cboBeanBindingAno1;
    private administracion.BeanBinding.CboBeanBindingMes cboBeanBindingMes1;
    private administracion.BeanBinding.CboBeanBindingZona cboBeanBindingZona1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JButton jbAceptar1;
    private javax.swing.JButton jbCancelar1;
    private javax.swing.JButton jbtImprimir1;
    private javax.swing.JCheckBox jchkInversion;
    private javax.swing.JPanel jpInversion;
    private javax.swing.JPanel jpOperativo;
    private javax.swing.JTable jtRequerimientos;
    private javax.swing.JTextField jtfCodCenCostos;
    private javax.swing.JTextField jtfCodProyecto;
    private javax.swing.JTextField jtfCodUnorganica;
    private javax.swing.JTextField jtfDesProyecto;
    private javax.swing.JTextField jtfDesUnOrganica;
    private javax.swing.JTextField jtfDescCenCostos;
    // End of variables declaration//GEN-END:variables

}
